package com.egaleye.core.log;

import org.springframework.aop.framework.autoproxy.AbstractBeanFactoryAwareAdvisingPostProcessor;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.aop.support.annotation.AnnotationMatchingPointcut;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.lang.annotation.Annotation;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by hyt on 2019/1/7.
 */
public class LogWebRequestPostProcessor extends AbstractBeanFactoryAwareAdvisingPostProcessor
        implements InitializingBean {

    private static final long serialVersionUID = -9155514899324500707L;

    private Class<? extends Annotation> classAnnotationType = Controller.class;

    private Class<? extends Annotation> methodAnnotationType= RequestMapping.class;

    @Override
    public void afterPropertiesSet() throws Exception {

        Set<String> excludePackages=new HashSet<>(2);
        excludePackages.add("org.springframework");
        excludePackages.add("springfox");

//        AnnotationMatchingPointcut pointcut = new AnnotationMatchingPointcut(this.classAnnotationType, true,
//                this.methodAnnotationType,true,excludePackages);
        //this.advisor = new DefaultPointcutAdvisor(pointcut, new LogHttpRequestContextAdvice());
        return;
    }
}
